import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
import math
import sys
from collections import deque


mpl.rcParams['font.sans-serif'] = ['SimHei']  # 用来正常显示中文标签
mpl.rcParams['axes.unicode_minus'] = False  # 用来正常显示负号
print(mpl.matplotlib_fname())
#定义文本框和箭头格式
decisionNode = dict(boxstyle="sawtooth", fc="0.8") #fc表示框填充色，0-1表示黑到白
leafNode = dict(boxstyle="round4", fc="0.8")
arrow_args = dict(arrowstyle="<-")

def createPlot():
    fig = plt.figure(1, facecolor='white')
    fig.clf()
    createPlot.axl = plt.subplot(111, frameon=False)
    plotNode('JCJD', (0.5, 0.1), (0.1, 0.5), decisionNode)
    plotNode('YJD', (0.8, 0.1), (0.3, 0.8), leafNode)
    plt.show()
def plotNode(nodeTxt, centerPt, parentPt, nodeType):
    # nodeTxt:节点文本， centerPt:子节点， parentPt:父节点， nodeType:节点样式
    createPlot.axl.annotate(nodeTxt, xy=parentPt,xycoords='axes fraction',\
                            xytext=centerPt, textcoords='axes fraction',\
                            va="center", ha="center", bbox=nodeType, arrowprops=arrow_args)


